package com.zls.utils;

import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

public class JedisPoolUtils {
    private static JedisPool jedisPool;
    private static final String HOST = "120.27.134.168";
    private static final int PORT = 6379;
    private static final String PASSWORD = "123";

    static {
        GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();
        jedisPool = new JedisPool(poolConfig, HOST, PORT, 3000, PASSWORD);
    }

    public static Jedis getResource(){
        return jedisPool.getResource();
    }

    public static void close(Jedis jedis){
        jedis.close();
    }
}
